#include <bits/stdc++.h>
using namespace std;
int a[100005],d[100005],v[100005],p[100005];
int main()
{
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	int t;
	cin>>t;
	while (t--)
	{
		int n,m,L,V;
		cin>>n>>m>>L>>V;
		for (int i=1;i<=n;i++)
		{
			cin>>d[i]>>v[i]>>a[i];
		}
		for (int i=1;i<=m;i++)
		{
			cin>>p[i];
		}
		sort(p+1,p+m+1);
		int z=0;
		for (int i=1;i<=n;i++)
		{ 
			if (a[i]>0)
			{
				int x=L-d[i];
				if (sqrt(v[i]*v[i]+2*a[i]*x)>V) z++;
			}
			else if (a[i]==0)
			{
				if (v[i]>V) z++;
			}
			else if (a[i]<0)
			{
				int x;
				for (int i=1;i<=m;i++)
				{
					if (p[i]>=d[i]) 
					{
						x=p[i]-d[i];
						break;
					}
				}
				if (sqrt(v[i]*v[i]+2*a[i]*x)>V) z++;
			}
		}
		cout<<z<<" ";
		int ans=0,fx=0,fy=0;
		for (int i=1;i<=n;i++)
		{
			if (a[i]>0 && fx==0) 
			{
				ans++;
				fx=1;
			}
			if (a[i]<0 && fy==0) 
			{
				ans++;
				fy=1;
			}
		}
		cout<<m-ans<<endl;
	}
	return 0;
}
